<template>
	<view>
		<view class="uni-list">
			<block v-for="(recruit, index) in listData" :key="index">
				<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="goDetail(recruit.id)">
					<view class="uni-media-list">
						<view class="uni-media-list-body">
							<view class="uni-media-list-text-top">{{ recruit.ZW }}</view>
							<view class="uni-media-list-text-middle">
								<span v-if="recruit.SSDS">{{ recruit.SSDS }}</span>
								<span v-if="recruit.NLYQ">{{ recruit.NLYQ }}</span>
								<span v-if="recruit.XQRS">{{ recruit.XQRS }}</span>
								<span v-if="recruit.ZCYQ">{{ recruit.ZCYQ }}</span>
							</view>
							<view class="uni-media-list-text-bottom">
								<text>{{ recruit.JGMC }}</text>
								<text>{{ recruit.publishDate }}</text>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<uni-load-more :status="status" :icon-size="16" :content-text="contentText" />
	</view>
</template>

<script>
	import { dateUtils } from  '../../../common/util.js';
	import apiConfig  from "/api/config.js"
	import CryptoJS from 'crypto-js'
	
	export default {
		data() {
			return {
				listData: [],
				last_id: '',
				status: 'more',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				},
				pageNum:1
			};
		},
		onLoad() {
			this.getList();
		},
		onPullDownRefresh() {
			this.pageNum = 1;
			this.getList();
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		methods: {
			isShow(rst){
				return rst?true:false;
			},
			getList() {
				const param = {
					action: 'getRecruitInfoList',
					pageSize:'20',
					pageNum:this.pageNum
				};
				uni.request({
					url: apiConfig.api_host + "/wsb/interface/txywryxc.do",
					data: param,
					success: data => {
						var decrypt = this.aes_decrypt(data.data)
						console.log("解密", decrypt);
						var rstData = JSON.parse(decrypt.replace(/[^\x20-\x7E\u4E00-\u9FFF]+/g, "")).data.data;
						console.log("招聘列表", rstData);
						this.listData = this.pageNum == 1? rstData : this.listData.concat(rstData);
						if(rstData && rstData.length > 0){
							this.pageNum = this.pageNum + 1;
						}
					},
					fail: (data, code) => {
						console.log('fail', data);
					}
				});
			},
			goDetail: function(e) {
				uni.navigateTo({
					url: '/pages/retire/main/recruitDetail?id='+e
				});
				return false;
			},
			aes_encrypt: function(word){
				let keyStr = "abc654321abc===+";//加密密钥
				let ivStr  = "abc654321abc===+";//矢量
			    keyStr = keyStr ? keyStr : 'hfhfuu8dolv98bt6';
			    var key  = CryptoJS.enc.Utf8.parse(keyStr);
			    var iv   = CryptoJS.enc.Utf8.parse(ivStr);
			    // var srcs = CryptoJS.enc.Utf8.parse(word);
			    var encrypted = CryptoJS.AES.encrypt(word, key, {
			        iv:iv,
			        mode:CryptoJS.mode.CBC,
			        padding: CryptoJS.pad.Pkcs7});
			    return encrypted.toString();
			},
			 
			//解密  
			aes_decrypt: function(word){  
				let keyStr = "abc654321abc===+";//加密密钥
				let ivStr  = "abc654321abc===+";//矢量
			    keyStr = keyStr ? keyStr : 'hfhfuu8dolv98bt6';
			    var key  = CryptoJS.enc.Utf8.parse(keyStr);//
			    var iv   = CryptoJS.enc.Utf8.parse(ivStr);
			    // const restoreBase64 = word.replace(/\-/g,'+').replace(/_/g,'/');
			    var restoreBase64=word.replace(/[\r\n]/g,'');
			 
			    var decrypt = CryptoJS.AES.decrypt(restoreBase64, key, {
			        iv:iv,
			        mode:CryptoJS.mode.CBC,
			        padding: CryptoJS.pad.ZeroPadding});
			    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
			}
		}
	};
</script>

<style>
	.banner {
		height: 360rpx;
		overflow: hidden;
		position: relative;
		background-color: #ccc;
	}

	.banner-img {
		width: 100%;
	}

	.banner-title {
		max-height: 84rpx;
		overflow: hidden;
		position: absolute;
		left: 30rpx;
		bottom: 30rpx;
		width: 90%;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 42rpx;
		color: white;
		z-index: 11;
	}

	.uni-media-list-logo {
		width: 180rpx;
		height: 140rpx;
	}

	.uni-media-list-body {
		height: auto;
		justify-content: space-around;
	}

	.uni-media-list-text-top {
		/* height: 60rpx;
		font-size: 28rpx;
		overflow: hidden; */
		height: 60rpx;
		font-size: 29rpx;
		overflow: hidden;
		font-weight: bold;
	}
	.uni-media-list-text-middle {
		height: 74rpx;
		font-size: 28rpx;
		overflow: hidden;
	}
	.uni-media-list-text-middle span {
		background-color: rgb(241, 241, 241);
		font-size: 12px;
		padding: 5px;
		border-radius: 2px;
		margin-right: 5px;
		color: #4c4c4c;
	}

	.uni-media-list-text-bottom {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		color:black;
	}
</style>
